package com.jiazhong.shixi.caichanguanli.controller;

import com.jiazhong.shixi.caichanguanli.bean.Assets;
import com.jiazhong.shixi.caichanguanli.bean.Logs;
import com.jiazhong.shixi.caichanguanli.mapper.LogsMapper;
import com.jiazhong.shixi.caichanguanli.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;

@RestController
@RequestMapping("/logs")
public class LogsController {
    @Autowired
    private LogsMapper logsMapper;

    @RequestMapping("/insert")
    public JsonResult insertLog( Logs sc) {
        logsMapper.insert(sc);
        JsonResult result = new JsonResult(true, 200, "success", "");
        return result;
    }

    @RequestMapping("/find")
    public JsonResult findByLogTime(String log_time) {
        List<Logs> list = logsMapper.findByLogTime(log_time);
        JsonResult result = new JsonResult(true, 200, list, "");
        return result;
    }

    @RequestMapping("/delete")
    public JsonResult deleteLog(Logs sc) {
        logsMapper.deleteById(sc);
        JsonResult result = new JsonResult(true, 200, "success", null);
        return result;
    }
}
